<template>

  <div class="app-container" >
    <div style="width:85%; height: 100%;   border: 1px solid white; float:left">





      <div>
        <el-form ref="elForm" :model="formData"  size="mini" label-width="95px">
          <el-row :gutter="25">
            <el-col :span="4">
              <el-form-item label=" 裁切模式" prop="field108">
                <el-select  @change="SetCameraCutMode" v-model="formData.field108" placeholder="请选择 裁切模式:" clearable :style="{width: '100%'}">
                  <el-option  v-for="(item, index) in field108Options"  :key="index" :label="item.label" :id="item.id"
                              :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="文件格式" prop="field109">
                <el-select @change = "toSetFileType"  v-model="formData.field109" placeholder="请选择文件格式:" id="FileType" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field109Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="色彩模式" prop="field120">
                <el-select id="ColorMode" @change = "toSetColorModel"  v-model="formData.field120" placeholder="请选择色彩模式:" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field120Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
           <!-- <el-col :span="4">
              <el-form-item label="图像质量" prop="field121">
                <el-select id="JpgQuality" @change = "toSetJpgQuality" v-model="formData.field121" placeholder="请选择图像质量:" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field121Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>-->
          <!--  <el-col :span="4">
              <el-form-item id="Select1" label="水印位置" prop="field127">
                <el-select v-model="formData.field127" placeholder="请选择位置" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field127Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item id="Text3" label="水印大小" prop="field126">
                <el-input v-model="formData.field126" placeholder="请输入大小" clearable :style="{width: '100%'}">
                </el-input>
              </el-form-item>
            </el-col>-->
            <!--<el-col :span="4">
              <el-form-item label="DPI" prop="field122">
                <el-select   id="DPI"  @change = "toSetDPI" v-model="formData.field122" placeholder="请选择DPI:" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field122Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>-->
            <!--<el-col :span="4"  style="visibility:hidden">
              <el-form-item label="DPI:" prop="field122">
                <el-select v-model="formData.field122" placeholder="请选择DPI:" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field122Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>-->

          <!--  <el-col :span="4">
              <el-form-item id="Checkbox3" label="添加水印" prop="field123">
                <el-checkbox-group v-model="formData.field123" size="medium">
                  <el-checkbox v-for="(item, index) in field123Options" :key="index" :label="item.value"
                               :disabled="item.disabled">{{item.label}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col :span="4">

              <el-form-item id="Select2" label="水印颜色" prop="field128">
                <el-select v-model="formData.field128" placeholder="请选择颜色" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field128Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>


-->


















         <!--   <el-col :span="4">
              <el-form-item id="Text1q" label="水印内容" prop="field124">
                <el-input v-model="formData.field124" placeholder="请输入水印内容" clearable :style="{width: '100%'}">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item id="Text2" label="水印透明度" prop="field125">
                <el-input v-model="formData.field125" placeholder="请输入透明度" clearable :style="{width: '100%'}">
                </el-input>
              </el-form-item>
            </el-col>-->
            <!--<el-col :span="4">
              <el-form-item id="Text3" label="水印大小" prop="field126">
                <el-input v-model="formData.field126" placeholder="请输入大小" clearable :style="{width: '100%'}">
                </el-input>
              </el-form-item>
            </el-col>-->
           <!-- <el-col :span="4">
              <el-form-item id="Select1" label="水印位置" prop="field127">
                <el-select v-model="formData.field127" placeholder="请选择位置" clearable :style="{width: '100%'}">
                  <el-option v-for="(item, index) in field127Options" :key="index" :label="item.label"
                             :value="item.value" :disabled="item.disabled"></el-option>
                </el-select>
              </el-form-item>
            </el-col>-->
          <!--  <el-col :span="4">
              <el-form-item id="Checkbox4" label-width="100px" label="添加时间水印  " prop="field111">
                <el-checkbox-group v-model="formData.field129" size="medium">
                  <el-checkbox v-for="(item, index) in field129Options" :key="index" :label="item.value"
                               :disabled="item.disabled">{{item.label}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>-->



          </el-row>

        </el-form>
        <el-button plain @click = "toSetWaterMarkParams()">生效水印参数设置</el-button>
        <el-button plain @click = "Cam_ZoomIna()">放大</el-button>

        <el-button plain  @click = "Cam_ZoomOuta()" >缩小</el-button>
        <el-button plain  @click = "Cam_BestSizea()" >适屏</el-button>
        <el-button plain  @click = "Cam_TrueSizea()" >1:1</el-button>
        <el-button plain  @click = "Cam_RotateLefta()" >左旋</el-button>
        <el-button plain  @click = "Cam_RotateRighta()" >右旋</el-button>
        <!--  <el-button plain  @click = "TakePhoto()" >拍照</el-button>-->
        <!--<el-button plain  @click = "Cam_Focus()" >对焦</el-button>-->
        <el-button plain  @click = "Cam_ShowVideoPropa()" >设置</el-button>
        <!--<el-button plain  @click = "HttpUploadFile()" >上传</el-button>-->

        <el-button plain  @click = "ToAddPDFFile()" >添加合并PDF文件</el-button>
        <el-button plain  @click = "ToCombinePDF()" >合并PDF</el-button>
        <!-- <el-button plain  @click = "ToAddMergeImageFile()" >添加合并图像文件</el-button>-->
        <!--  <el-button plain  @click = "ToMergeImages()" >合并图像</el-button>-->
        <el-button plain  @click = "ToDeleteFile()" >删除</el-button>
        <!--<el-button plain  @click = "LoadCameraDocument()" >删除4</el-button>-->
      </div>
      <br>

      <div style="background-color:#f8f8f9;border: 1px solid white;margin-top: 5px;" >

        <div  id='CameraCtl' style="width: 650px; height:400px;margin:10px auto;">  </div>



        <br />
        <div style="text-align: center">
          <!-- 设备
           <el-select v-model="value" placeholder="请选择">
             <el-option
               v-for="item in options"
               :key="item.value"
               :label="item.label"
               :value="item.value"
             onchange="SelectDevice()">
             </el-option>
           </el-select>
           分辨率
           <el-select v-model="value" placeholder="请选择">
             <el-option
               v-for="item in options"
               :key="item.value"
               :label="item.label"
               :value="item.value"
               onchange="SelectDevice()">
             </el-option>
           </el-select>-->
          <a style="
    vertical-align: middle;

    font-size: 14px;
    color: #606266;
    line-height: 40px;

    -webkit-box-sizing: border-box;
    box-sizing: border-box;
font-weight: bold;
">设备</a>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <!--<el-select id="DevName" @click = "SelectDevice()"   clearable >

          </el-select>-->
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <select style="    height: 28px;
    line-height: 28px;width: 150px;
    " id="DevName"  @click = "SelectDevice()"></select>
          <span v-html="'\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'"/>
          <a style="
    vertical-align: middle;

    font-size: 14px;
    color: #606266;
    line-height: 40px;

    -webkit-box-sizing: border-box;
    box-sizing: border-box;
font-weight: bold;
">分辨率</a>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <!-- <el-select id="DevResolution" @click = "SelectResolution()"  clearable >

           </el-select>-->




          <select style="    height: 28px;
    line-height: 28px;width: 150px" id="DevResolution" @click = "SelectResolution()"></select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <el-button plain @click = "toOpenCamera">切换设备</el-button>
          <!-- <el-button plain @click = "toCloseCamera">关闭设备</el-button>-->
          <!-- <input type = "button" value = " 打开设备 " onclick = "toOpenCamera();"/>
           <input type = "button" value = " 关闭设备 " onclick = "toCloseCamera();"/>-->
        </div>
        <br />
      </div>

      <br />





    </div>

    <div style="width:15%; height: 150px; border: 1px solid white;  float:left;margin-top: 5px">
      <el-button  @click = "TakePhoto()" style="margin: 40px 75px 75px 75px;color: white;background-color:#5676e9;height: 50px">拍摄</el-button>
    </div>
    <div style="width:15%; height: 500px; border: 5px solid white; float:left ;">
      <a>拍照图片</a>
      <br />
      <img id="CameraPhoto"  src="" style="width: 198px;height: 198px;"  />
      <br />
      <br />
      <!--<div style="width: 198px;height: 70px;">
        <textarea  style="width:100%; height:100%" id="TextInfo" cols="20" rows="2"></textarea>
      </div>-->
      <a>消息窗口</a>
      <div style="width: 198px;height: 170px;">
        <el-input
          type="textarea"
          :rows="8"
          style="width:100%; height:100%"
          v-model="textarea"
          id="TextInfo">
        </el-input>
      </div>
    </div>

  </div>
</template>
<style>

</style>
<script>
  import { listVerify, getVerify, delVerify, addVerify, updateVerify,updateP } from "@/api/module/gs/verify/verify";

  import {Cam_Close,Cam_ControlInit,Cam_ZoomIn,WebSocketConnect,DeleteFile,Cam_Open,Cam_SetCutMode,Cam_SetFileType,
    Cam_AddMergeImageFile,Cam_ZoomOut,Cam_BestSize,Cam_TrueSize,Cam_RotateLeft,Cam_RotateRight,Cam_SetColorMode,
    SetDpi,SetWaterMark,Cam_SetJpgQuality,Cam_ShowVideoProp,Cam_Photo,Cam_CombinePDF,Cam_AddImgFileToPDF



  } from "@/api/module/gs/gpyhs";
  export default {
    name: "Verify",
    mounted() {
      this.LoadCameraDocument()
    },
    data() {
      return {
        formData: {
          field108: undefined,
          field109: undefined,
          field120: undefined,
          field121: undefined,
          field122: undefined,
          field123: [],
          field124: "水印",
          field125: "100",
          field126: "80",
          field127: 4,
          field128: 0,
          field129: [],
        },
        locfilepath:[] || "",
        field108Options: [{
          "id":"Radio1",
          "label": "不裁切",
          "value": "V1"

        }, {
          "label": "手动裁切",
          "value": "V2",
          "id":"Radio2"
        }, {
          "label": "自动裁切",
          "value": "V3",
          "id":"Radio3"
        }, {
          "label": "自定义",
          "value": "V4",
          "id":"Radio4"
        }],
        field109Options: [{
          "label": "jpg",
          "value": 0
        }, {
          "label": "png",
          "value": 1
        }, {
          "label": "tif",
          "value": 2
        }, {
          "label": "pdf",
          "value": 3
        }],
        field120Options: [{
          "label": "彩色",
          "value": 0
        }, {
          "label": "灰度",
          "value": 1
        }, {
          "label": "黑白",
          "value": 2
        }],
        field121Options: [{
          "label": "10",
          "value": 0
        }, {
          "label": "20",
          "value": 1
        }, {
          "label": "30",
          "value": 2
        }, {
          "label": "40",
          "value": 3
        }, {
          "label": "50",
          "value": 4
        }, {
          "label": "60",
          "value": 5
        }, {
          "label": "70",
          "value": 6
        }, {
          "label": "80",
          "value": 7
        }, {
          "label": "90",
          "value": 8
        }, {
          "label": "100",
          "value": 9
        }],
        field122Options: [{
          "label": "100",
          "value": 0
        }, {
          "label": "200",
          "value": 1
        }, {
          "label": "300",
          "value": 2
        }, {
          "label": "400",
          "value": 3
        }, {
          "label": "500",
          "value": 4
        }, {
          "label": "600",
          "value": 5
        }],
        field123Options: [{
          "label": "",
          "value": 0
        }],
        field127Options: [{
          "label": "左上",
          "value": 0
        }, {
          "label": "右上",
          "value": 1
        }, {
          "label": "左下",
          "value": 2
        }, {
          "label": "右下",
          "value": 3
        }, {
          "label": "中间",
          "value": 4
        }],
        field128Options: [{
          "label": "红色",
          "value": 0
        }, {
          "label": "绿色",
          "value": 1
        }, {
          "label": "蓝色",
          "value": 2
        }, {
          "label": "青色",
          "value": 3
        }, {
          "label": "黄色",
          "value": 4
        }, {
          "label": "白色",
          "value": 5
        }, {
          "label": "黑色",
          "value": 6
        }],
        field129Options: [{
          "label": "",
          "value": 0
        }],
        value: ''
      };
    },
    created() {

    },

    methods: {


      //时间格式化显示
      formatDate(time) {
        var date = new Date(time);
        var year = date.getFullYear(),
          month = date.getMonth() + 1,
          day = date.getDate(),
          hour = date.getHours(),
          min = date.getMinutes(),
          sec = date.getSeconds();
        var newTime = year +
          (month < 10 ? '0' + month : month) +
          (day < 10 ? '0' + day : day) +
          (hour < 10 ? '0' + hour : hour) +
          (min < 10 ? '0' + min : min) +
          (sec < 10 ? '0' + sec : sec) ;
        return newTime;
      },


      sleep(milliSeconds) {
        var startTime = new Date().getTime();
        while (new Date().getTime() < startTime + milliSeconds);
      },

      ShowInfo(op) {
        var obj = document.getElementById("TextInfo");
        obj.value = obj.value + "\r\n" + op
      },


      /*----------------------------------------------------
      ---（必须重写该函数）返回获取的设备数目及设备名称  ---
      -----------------------------------------------------*/
      GetDevCountAndNameResultCB(devCount, devNameArr) {

        if (devCount > 0) {

          var obj = document.getElementById("DevName");
          obj.options.length = 0;
          for (var i = 0; i < devCount; i++) {
            var objOption = document.createElement("option");
            objOption.text = devNameArr[i];
            objOption.value = i;
            obj.options.add(objOption);
          }
          obj.selectedIndex = 0;
          var CamID = obj.selectedIndex;

          //获取分辨率
          Cam_GetDevResolution(CamID);

        }
        else {
          ShowInfo("没有发现合适的设备！");
        }
      },

      /*---------------------------------------------------
      ---  （必须重写该函数）返回获取的设备分辨率信息   ---
      ----------------------------------------------------*/
      GetResolutionResultCB(resCount, resArr) {

        if (resCount > 0) {
          var selectIndex = 0;
          var obj = document.getElementById("DevResolution");
          obj.options.length = 0;
          for (var i = 0; i < resCount; i++) {
            var objOption = document.createElement("option");
            objOption.text = resArr[i];
            objOption.value = i;
            obj.options.add(objOption);
            //默认500万分辨率打开
            if (resArr[i] == "2592*1944") {
              selectIndex = i;
            }
          }
          obj.selectedIndex = selectIndex;

          //打开摄像头
          Cam_Close();
          //sleep(100);
          var restr = obj[obj.selectedIndex].text;
          var pos = restr.lastIndexOf("*");
          var width = parseInt(restr.substring(0, pos));
          var height = parseInt(restr.substring(pos + 1, restr.length));
          var CamID = document.getElementById("DevName").selectedIndex;
          Cam_Open(CamID, width, height);
        }
        else {
          ShowInfo("获取分辨率信息失败！");
        }
      },


      /*---------------------------------------------------
      ---     （必须重写该函数）返回摄像头开启状态      ---
      ----------------------------------------------------*/
      GetCameraOnOffStatus(status) {
        if (status == 0) {
          ShowInfo("切换设备成功");
          //Cam_Rotate(1);   // 0-> 0度, 1->90度, 2->180度, 3->270度
        }
        else {
          ShowInfo("切换设备失败!");
        }

      },


//    /*---------------------------------------------------
//    --------     （必须重写该函数）当前拍照状态 ---------
//    ----------------------------------------------------*/
//    function GetCaptrueStatusResultCB(status) {
//        if (status == 0) {
//            ShowInfo("拍照完成");
//        }
//        else {
//            ShowInfo("正在拍摄...");
//        }

//    }


      /*---------------------------------------------------
      --------     （必须重写该函数）拍照结果     ---------
      ----------------------------------------------------*/
      GetCaptrueImgResultCB( flag, path , base64Str) {
        if (flag == 0) {
          var obj = document.getElementById("CameraPhoto");
          obj.src = "data:;base64," + base64Str;
          if (path == "") {
            ShowInfo("拍照成功");
          }
          else {
            ShowInfo("拍照成功，图片保存位置：" + path);
          }
        }
        else {
          ShowInfo("拍照失败!");
        }

      },


      /*---------------------------------------------------
      ------  （必须重写该函数）身份证信息返回结果   ------
      ----------------------------------------------------*/
      GetIdCardInfoResultCB(flag, Name, Sex, Nation, Born, Address, CardNum, IssuedAt, EffectedDate, CardImgPath, CardImgBase64) {
        if (flag == 0) {
          document.getElementById("CardName").value = Name;
          document.getElementById("CardSex").value = Sex;
          document.getElementById("CardNation").value = Nation;
          document.getElementById("CardBorn").value = Born;
          document.getElementById("CardAddress").value = Address;
          document.getElementById("CardNum").value = CardNum;
          document.getElementById("CardIssuedAt").value = IssuedAt;
          document.getElementById("CardEffectDate").value = EffectedDate;
          var obj = document.getElementById("IdCardPhoto");
          obj.src = "data:;base64," + CardImgBase64;
          ShowInfo("读卡成功");
        }
        else {
          ShowInfo("读卡失败!");
        }

      },



      /*-------------------------------------------------------------------
      ------  （必须重写该函数）身份证信息及正反面合并照片返回结果   ------
      --------------------------------------------------------------------*/
      GetIdCardInfoAndImgResultCB(flag, Name, Sex, Nation, Born, Address, CardNum, IssuedAt, EffectedDate, CardImgPath, CardHeadImgBase64, CardImgBase64) {
        if (flag == 0) {
          document.getElementById("CardName").value = Name;
          document.getElementById("CardSex").value = Sex;
          document.getElementById("CardNation").value = Nation;
          document.getElementById("CardBorn").value = Born;
          document.getElementById("CardAddress").value = Address;
          document.getElementById("CardNum").value = CardNum;
          document.getElementById("CardIssuedAt").value = IssuedAt;
          document.getElementById("CardEffectDate").value = EffectedDate;
          var obj = document.getElementById("IdCardPhoto");
          obj.src = "data:;base64," + CardHeadImgBase64;
          var obj = document.getElementById("CameraPhoto");
          obj.src = "data:;base64," + CardImgBase64;
          ShowInfo("读卡成功");
        }
        else {
          ShowInfo("读卡失败!");
        }

      },


      /*---------------------------------------------------
      ------  （必须重写该函数）条码二维码识别返回结果------
      ----------------------------------------------------*/
      QrBarCodeRecogResultCB(flag,codeStr) {
        if (flag == 0)
          ShowInfo("条码/二维码 识别结果:" + codeStr);
        else
          ShowInfo("未识别到内容!");
      },



      /*********************
       ***    初始化操作  ***
       **********************/


      LoadCameraDocument() {

        if (!window.WebSocket) {
          alert("浏览器不支持HTML5,请更新浏览器或者使用其它浏览器1");
        }
        //console.log("LoadCameraDocument");

        const obj = document.getElementById("CameraCtl");
        Cam_ControlInit(obj,0, 0, 600, 400);
      },





      /*********************
       ***    打开摄像头  ***
       **********************/
      toOpenCamera() {
        const CamID = document.getElementById("DevName").selectedIndex;

        const obj = document.getElementById("DevResolution");
        console.log(obj)
        const restr = obj[obj.selectedIndex].text;
        const pos = restr.lastIndexOf("*");
        const width = parseInt(restr.substring(0, pos));
        const height = parseInt(restr.substring(pos + 1, restr.length));
        Cam_Open(CamID, width, height);

      },

      /*********************
       ***    关闭摄像头  ***
       **********************/
      toCloseCamera() {
        Cam_Close();
      },


      /*********************
       ***    切换摄像头  ***
       **********************/
      SelectDevice() {
        var CamID = document.getElementById("DevName").selectedIndex;
        //获取分辨率
        Cam_GetDevResolution(CamID);
      },


      /*********************
       ***    切换分辨率  ***
       **********************/
      SelectResolution() {
        var obj = document.getElementById("DevResolution");
        var restr = obj[obj.selectedIndex].text;
        var pos = restr.lastIndexOf("*");
        var width = parseInt(restr.substring(0, pos));
        var height = parseInt(restr.substring(pos + 1, restr.length));
        var CamID = document.getElementById("DevName").selectedIndex;
        Cam_Open(CamID, width, height);
      },


      /*********************
       ***       拍照     ***
       **********************/
      TakePhoto() {

        var name = this.formatDate(new Date().getTime());

        var obj = document.getElementById("FileType");
        var path;

        Cam_SetFileType(obj.selectedIndex); //设置文件格式
        if (obj.selectedIndex == 0) {
          path = "D:\\" + name + ".jpg";
        }
        else if (obj.selectedIndex == 1) {
          path = "D:\\" + name + ".png";
        }
        else if (obj.selectedIndex == 2) {
          path = "D:\\" + name + ".tif";
        }
        else if (obj.selectedIndex == 3) {
          path = "D:\\" + name + ".pdf";
        }
        else {
          path = "D:\\" + name + ".jpg";
        }
        this.toSetDPI();
        this.locfilepath=path;
        Cam_Photo(path);  //主摄像头拍照
        //Cam_Photo("");  //主摄像头拍照

      },


      SetCameraCutMode() {
        console.log(document.getElementById("Radio1").checked+"88")
        //console.log(this.data.field108Options.id+"8")
        console.log(this.formData.field108+"108")
        if (//document.getElementById("Radio1").checked
          this.formData.field108=="V1"
        ) {
          Cam_SetCutMode(0);

        }
        if (//document.getElementById("Radio3").checked
          this.formData.field108=="V3"
        ) {
          Cam_SetCutMode(1);
        }
        if (//document.getElementById("Radio2").checked
          this.formData.field108=="V2"
        ) {
          Cam_SetCutMode(2);
        }
        if (//document.getElementById("Radio4").checked
          this.formData.field108=="V4"
        ) {

          Cam_SetCutMode(3);
          //设置裁剪区域
          //toSleep(100);
          //console.log("SetCustomArea");
          SetCustomArea(3000,3000,9000,9000);
        }
      },


      /*********************
       ***    读取身份证  ***
       **********************/
      GetIdCardInfo() {
        var path = "D:\\IdCard.jpg";
        //Cam_ReadIdCard(path);
        //Cam_ReadIdCard("");
        Cam_ReadIdCardEx(path);
      },


      /*********************
       ***    设置文件格式  ***
       **********************/
      toSetFileType() {
        var obj = document.getElementById("FileType");

        Cam_SetFileType(obj.selectedIndex);
      },


      /*********************
       ***    设置色彩模式  ***
       **********************/
      toSetColorModel() {
        var obj = document.getElementById("ColorMode");

        //Cam_SetColorMode(obj.selectedIndex);
        Cam_SetColorMode(this.formData.field120);
      },


      /*********************
       ***    设置JPG图像质量  ***
       **********************/
      toSetJpgQuality() {
        //var obj = document.getElementById("JpgQuality");


        //var val = parseInt(obj[obj.selectedIndex].text);

        Cam_SetJpgQuality(this.formData.field121);
      },

      /*********************
       ***    设置DPI  ***
       **********************/
      toSetDPI() {
        //var obj = document.getElementById("DPI");
        //var val = parseInt(obj[obj.selectedIndex].text);

        //SetDpi(this.formData.field122, this.formData.field122);
        SetDpi(300, 300);
      },


      /*********************
       ***    设置去黑边  ***
       **********************/
      toSetDeleteBlackEdge() {
        var obj = document.getElementById("Checkbox1");
        if (obj.checked) {
          Cam_SetDeleteBlackEdge(1);
        }
        else {
          Cam_SetDeleteBlackEdge(0);
        }
      },

      /*********************
       ***    设置去底色  ***
       **********************/
      toSetDeleteBgColor() {
        var obj = document.getElementById("Checkbox2");
        if (obj.checked) {
          Cam_SetDeleteBgColor(1);
        }
        else {
          Cam_SetDeleteBgColor(0);
        }
      },


      /*---------------------------------------------------
      --------     （必须重写该函数）上传结果     ---------
      ----------------------------------------------------*/
      HttpResultCB(flag, ResultStr) {
        if (flag == 0) {
          alert("上传成功 :" + ResultStr);
        }
        else {
          alert("上传失败！");
        }
      },


      /*********************
       ******    上传  ******
       **********************/
      HttpUploadFile() {

        var filePath = "D:\\test.pdf";
        //var url = "http://112.27.213.220:2201/interface/FileUploadCode.jsp";

        //var url = "http://localhost:9005/MyServletTest/upload";
        var url = "http://localhost:4523/UploadFile.ashx";
        //var url = "http://localhost:9005/MyServletTest/upload";
        UploadFile(url, filePath);

      },


//从摄像头中识别二维码
      RecogQrCodeFromCamera(type){
        Cam_RecogQrBarCodeFromCamera(type)
      },

//从图片文件中识别二维码
      RecogBarCodeFromFile(type) {
        var imgpath = "D:\\123.jpg";
        Cam_RecogQrBarCodeFromFile(type, imgpath)
      },




//添加要合并的PDF文件
      ToAddPDFFile() {
//        Cam_AddImgFileToPDF("D:\\111.jpg");
//        sleep(100);
//        Cam_AddImgFileToPDF("D:\\222.jpg");
//        sleep(100);
//        Cam_AddImgFileToPDF("D:\\333.jpg");
//        sleep(100);
//        Cam_AddImgFileToPDF("D:\\444.jpg");
//        sleep(100);
//        Cam_AddImgFileToPDF("D:\\555.jpg");
//        sleep(100);

        //Cam_CombinePDF("D:\\test.pdf");

        Cam_AddImgFileToPDF("");

      },

      /*---------------------------------------------------
      --------     添加合并的PDF文件返回结果     ---------
      ----------------------------------------------------*/
      AddImgFileToPDFResultCB(flag, base64Str)
      {
        if (flag == 0) {
          ShowInfo("添加合并的PDF文件成功");
          var obj = document.getElementById("CameraPhoto");
          obj.src = "data:;base64," + base64Str;
        }
        else {
          ShowInfo("添加合并的PDF文件失败!");
        }
      },


//PDF合并测试
      ToCombinePDF() {

        const name = "D:\\" + this.formatDate(new Date().getTime())+ ".pdf";
        Cam_CombinePDF(name);
        // Cam_CombinePDF("");
      },

      /*---------------------------------------------------
      --------     （必须重写该函数）合并PDF结果     ---------
      ----------------------------------------------------*/
      PdfCombineResultCB(flag, PdfBase64Str) {
        if (flag == 0) {
          ShowInfo("合并PDF完成");
          console.log(PdfBase64Str);
        }
        else {
          ShowInfo("合并PDF失败!");
        }
      },


//添加要合并的图像文件
      ToAddMergeImageFile() {
        Cam_AddMergeImageFile("");
        //sleep(100);
      },
      //放大
      Cam_ZoomIna(){
        Cam_ZoomIn();
      },
      //缩小
      Cam_ZoomOuta(){
        Cam_ZoomOut();
      },
      //适屏
      Cam_BestSizea(){
        Cam_BestSize();
      },
      //1:1
      Cam_TrueSizea(){
        Cam_TrueSize();
      },
      //左旋
      Cam_RotateLefta(){
        Cam_RotateLeft();
      },
      //右旋
      Cam_RotateRighta(){
        Cam_RotateRight();
      },
      //设置
      Cam_ShowVideoPropa(){
        Cam_ShowVideoProp();
      },
      /*---------------------------------------------------
      --------     添加合并图像文件返回结果     ---------
      ----------------------------------------------------*/
      AddMergeImageFileResultCB(flag, base64Str) {
        if (flag == 0) {
          ShowInfo("拍摄成功");
          var obj = document.getElementById("CameraPhoto");
          obj.src = "data:;base64," + base64Str;
        }
        else {
          ShowInfo("添加合并图像文件失败!");
        }
      },


//图像合并测试
      ToMergeImages() {
        Cam_MergeImages("D:\\merge.jpg",0);
      },

      /*---------------------------------------------------
      --------     （必须重写该函数）图像合并结果     ---------
      ----------------------------------------------------*/
      MergeImagesResultCB(flag, base64Str) {
        if (flag == 0) {
          ShowInfo("图像合并完成");
          var obj = document.getElementById("CameraPhoto");
          obj.src = "data:;base64," + base64Str;
        }
        else {
          ShowInfo("图像合并失败!");
        }
      },




      /*---------------------------------------------------
      -------（必须重写该函数）获取驱动盘符返回结果--------
      ----------------------------------------------------*/
      GetDriveResultCB(driveStr) {
        if (driveStr == "") {
          ShowInfo("获取盘符失败!");
        }
        else {
          ShowInfo(driveStr);
        }
      },


//设置水印
      toSetWaterMarkParams() {
        var isAddMark;
        var isAddTime;
        var wTransp;
        var wPos;
        var wSize;
        var wColor;
        var szInfo;
        var obj = document.getElementById("Checkbox3");
        console.log(this.formData.field123+"888989")
        if (this.formData.field123=="0"){
          isAddMark = 1;
        }

        else{
          isAddMark = 0;
        }

        obj = document.getElementById("Checkbox4");
        if (this.formData.field129=="0")
          isAddTime = 1;
        else
          isAddTime = 0;
        //szInfo = document.getElementById("Text1").value;   //水印内容
        szInfo=this.formData.field124;
        console.log(this.formData.field124+"855")
        //wTransp = parseInt(document.getElementById("Text2").value); //透明度
        wTransp = parseInt(this.formData.field125);
        console.log(wTransp+"866")
        // wSize = parseInt(document.getElementById("Text3").value);   //水印大小
        wSize= parseInt(this.formData.field126);
        // wPos = document.getElementById("Select1").selectedIndex;   //水印位置
        wPos=this.formData.field127;
//  wColor = document.getElementById("Select2").selectedIndex;   //水印颜色
        wColor=this.formData.field128;
        SetWaterMark(isAddMark, 0, isAddTime, wTransp, wPos, wSize, wColor, szInfo);  //生效水印设置
      },



//删除文件
      ToDeleteFile() {
        //  var path = this.data.locfilepath;
        const path =   this.locfilepath;
        console.log( this.locfilepath+"path")
        DeleteFile(path);
      },

//删除文件返回结果
      GetDeleteFileResultCB(flag) {
        if (flag == 0) {
          ShowInfo("删除文件成功");
        }
        else {
          ShowInfo("删除文件失败！");
        }
      },


    }
  };
</script>
